<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models;

use Carbon\Carbon;

/**
 * Class UserBalanceLog
 * 
 * @property int $id
 * @property int|null $uid
 * @property int|null $type
 * @property string|null $amount
 * @property string|null $msg
 * @property Carbon|null $create_at
 * @property Carbon|null $update_at
 * @property Carbon|null $delete_at
 *
 * @package App\Models
 */
class UserBalanceLog extends BaseModels
{
	protected $table = 'zh_user_balance_log';


	const COMMISSION_IN = 1; //分销入账

	const OUT = 2; //提现出账

	protected $casts = [
		'uid' => 'int'
	];

	protected $dates = [
		'create_at',
		'update_at',
		'delete_at'
	];

	protected $fillable = [
		'uid',
        'type',
		'amount',
		'msg',
		'create_at',
		'update_at',
		'delete_at'
	];


	protected $appends = ['type_string'];

	public function getTypeStringAttribute()
    {
        switch ($this->type){
            case self::COMMISSION_IN:
                return '分销入账';
            case self::OUT:
                return '提现出账';
            default:
                return '';
        }
    }
}
